package bsc.war.ajax;



import bsc.ejb.entity.Person;
import bsc.ejb.entity.ScoreDomain;
import bsc.ejb.metadata.Colorimetry;
import bsc.ejb.metadata.Framework;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author Miguel Angel
 */
public class AddActionPlan extends AbstractController  {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
         HttpServletResponse response) throws Exception {

        try {
            
            DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");
            ScoreDomain currentSD = (ScoreDomain) request.getSession().getAttribute("currentScoreDomain");
            Framework framework = (Framework) request.getSession().getAttribute("framework");

            String scoreCard = request.getParameter("scoreCard");

            List<Colorimetry> colorimetries = delegate.findColorimetry(framework, Boolean.TRUE);
            List<Person> persons= delegate.findPerson(currentSD);

            
            request.setAttribute("colorimetries", colorimetries);
            request.setAttribute("persons", persons);
            request.setAttribute("scoreCard", scoreCard);
            
        } catch (Exception e) {
            System.err.println("Caught exception: "+e);
            e.printStackTrace();
        }

         return new ModelAndView("addActionPlan");
    }

}
